package com.example.mobile2021606140lhq04011;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle;
    private ImageView ivMainLight;
    private Button btnMainOffOn;

    private boolean fanStatus=false;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btnMainOffOn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (fanStatus){
                    ivMainLight.setImageResource(R.drawable.fan_off);
                    fanStatus=false;
                }else {
                    ivMainLight.setImageResource(R.drawable.fan_on);
                    fanStatus=true;
                }



            }
        });
//        btnMainOffOn.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                ivMainLight.setImageResource(R.drawable.fan_on);
//            }
//        });
    }

    private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tv_main_title);
        ivMainLight = (ImageView) findViewById(R.id.iv_main_light);
        btnMainOffOn = (Button) findViewById(R.id.btn_main_OffOn);
    }
}